<template>
  <div>
    <div>
      <TitleNode title-text="城市" v-if="showTitle" class="al-m-10px"/>
      <div class="al-flex-wrap">
        <div v-for="(item, index) in cityData"

              @click="sendData(item.name)"
              :key="index" class="al-m-10px al-cursor-pointer al-hover-color-blue al-flex-container-center-v">
          <div :class="activeCity == item.name ? 'al-border-capsule al-gradient-to-top-light-blue al-text-color-white ':''"
                class="al-flex-container-center-h" style="width: 60px">
            {{item.name}}
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import TitleNode from "../../../components/public/TitleNode";
  export default {
    name: "CitySelectorComponent",
    //组件
    components: {TitleNode},
    //属性
    props: {
      showTitle:{
        type: Boolean,
        default: false
      },

      cityData:{
        type: Array,
        default: undefined
      },

      defaultActiveCity:{
        type: String,
        default: '全部'
      }
    },

    //数据
    data() {
      return {

        activeCity: this.$props.defaultActiveCity
      }
    },

    //挂载完成时
    mounted() {

    },

    //方法
    methods: {
      sendData(name){
        this.activeCity = name;
        this.$emit("getSonData", name);
      }
    },

    //计算属性
    computed: {},

    //监听
    watch: {}
  }
</script>

<style scoped>

</style>
